<template>
  <div style="padding-left: 1.25rem;padding-right: 1.25rem;padding-top: 70px;">
    <el-row :gutter="20">
      <el-col :span="6" style="height: 750px;">
        <el-input @focus="getFoodListByShortCode" placeholder="菜品助词码(大写)" prefix-icon="el-icon-search"
                  v-model="shortCode"></el-input>
        <br/>
        <el-card v-if="EnglishKeyBordVisle">
          <EnglishKeyBord @getLetter="getLett"></EnglishKeyBord>
        </el-card>
        <br/>
        <el-card shadow="never" style="">
          <div>桌号:{{ openDeskInfo.diningTableNo }}桌/{{ openDeskInfo.eatNumer }}人</div>
          <br/>
          <div>开台时间:{{ openDeskInfo.openTime }}</div>
          <br/>
          <div>单号:{{ openDeskInfo.orderId }}</div>
        </el-card>
        <br/>
        <el-card shadow="never" style="">
          <el-table :data="selectFoodList" style="width: 100%;cursor: pointer;" height="360px"
                    @row-click="superRequirement" highlight-current-row="true">
            <el-table-column prop="foodName" label="品名">
              <template slot-scope="scope">
                <div>
									<span v-show="scope.row.giveFoodStatus === 1" style="color: red;">
										[赠
										<span>{{ scope.row.giveNum }}</span>
										]
									</span>
                  <span v-show="scope.row.placeOrderSign" style="color: red;">[下]</span>
                  <span v-show="scope.row.discount && scope.row.discount !== '10'"
                        style="color: red;">[<span>{{ scope.row.discount }}折</span>]</span>
                  <span v-show="scope.row.singleFoodSign === 1" style="color: red;">[转]</span>
                  <span v-show="scope.row.retreatSign === 1" style="color: red;">
										[退
										<span>{{ scope.row.retreatNum }}</span>
										]
									</span>
                  {{ scope.row.foodName }}
                </div>
                <div style="color: forestgreen;font-size: 0.5rem;">{{ scope.row.requirementName }}</div>
              </template>
            </el-table-column>
            <el-table-column prop="name" label="数量">
              <template slot-scope="scope">
                <i class="el-icon-remove-outline cursor" @click="removeFood(scope.row)"></i>
                &nbsp;&nbsp;{{ scope.row.foodNum }}&nbsp;&nbsp;
                <i class="el-icon-circle-plus-outline cursor" @click="addFood(scope.row)"></i>
              </template>
            </el-table-column>
            <el-table-column prop="price" label="金额">
              <template slot-scope="scope">
                <div style="color: red;">￥{{ Number(scope.row.total) }}元</div>
                <!-- <div v-if="scope.row.giveFoodStatus === 1" style="color: red;text-decoration:line-through">￥{{ Number(scope.row.total) }}元</div> -->
              </template>
            </el-table-column>
          </el-table>
        </el-card>
        <br/>
        <el-card shadow="never">
          <el-row :gutter="20">
            <el-col :span="12">
              <a style="cursor: pointer;text-decoration: none;" @click="xiadan">
                <div class="seatNum"
                     style="width: 100%;height: 50px;background-color:#32CD32;padding-top: 18px;font-weight: 800;">下单
                </div>
              </a>
            </el-col>
            <el-col :span="12">
              <a style="cursor: pointer;text-decoration: none;" @click="jiezhang">
                <div class="seatNum"
                     style="width: 100%;height: 50px;background-color:#F08080;padding-top: 18px;font-weight: 800;">
                  结账:￥{{ totalMoney }}元
                </div>
              </a>
            </el-col>
          </el-row>
          <br/>
          <el-row :gutter="20">
            <el-col :span="12">
              <a style="cursor: pointer;text-decoration: none;" @click="print">
                <div class="seatNum"
                     style="width: 100%;height: 50px;background-color:gray;padding-top: 18px;font-weight: 800;">打印清单
                </div>
              </a>
            </el-col>
            <el-col :span="12">
              <a style="cursor: pointer;text-decoration: none;" @click="clearSelectFood">
                <div class="seatNum"
                     style="width: 100%;height: 50px;background-color:#21BD86;padding-top: 18px;font-weight: 800;">清空
                </div>
              </a>
            </el-col>
          </el-row>
        </el-card>
      </el-col>
      <el-col :span="2" style="height: 750px;overflow: auto;">
        <!-- <el-card class="cursor" shadow="never" style="background-color: blueviolet;"></el-card>
        <br /> -->
        <a style="cursor: pointer;text-decoration: none;" class="cursor" @click="openDesk">
          <el-card shadow="never">
            <svg t="1616314391254" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
                 p-id="2180" width="24" height="24">
              <path
                d="M284.300863 797.800857c9.099966 0 18.299931-3.499987 25.299904-10.49996 13.999947-13.999947 13.999947-36.599861 0-50.499809l-188.999284-189.099283h544.797936c19.699925 0 35.699865-15.999939 35.699864-35.699865s-15.999939-35.699865-35.699864-35.699865H120.501483l189.099284-189.099283c13.999947-13.899947 13.999947-36.599861 0-50.499809-13.999947-13.999947-36.599861-13.999947-50.499809 0L34.20181 461.602131c-27.799895 27.899894-27.699895 73.199723 0.1 100.999617L259.000959 787.300897c6.999973 6.999973 16.199939 10.49996 25.299904 10.49996z"
                fill="#27D0D8"
                p-id="2181"
              ></path>
              <path
                d="M958.798307 51.803684C925.398434 18.40381 880.998602 0.00388 833.698781 0.00388h-524.998011c-47.099822-0.299999-91.599653 16.799936-125.499524 49.499812-33.799872 32.699876-52.8998 76.699709-53.699797 123.799531v5.799978l71.39973 0.999997 0.199999-4.999981c0.1-1.499994 0-2.899989-0.1-4.299984 1.299995-26.599899 12.599952-51.299806 31.79988-69.899735C253.000981 81.403572 280.000879 71.003611 308.100773 71.403609h525.598008c28.199893 0 54.699793 10.999958 74.599717 30.899883s30.899883 46.399824 30.899883 74.599718v668.397467c0 59.099776-48.099818 107.199594-107.199593 107.199594H308.100773c-61.199768 0-106.899595-67.699743-106.899595-128.199514 0-19.699925-15.999939-35.699865-35.699865-35.699865s-35.699865 15.999939-35.699865 35.699865c0 94.399642 73.299722 199.699243 178.399324 199.699243H831.998788c98.499627 0 178.599323-80.099696 178.599323-178.599323V177.003209c0-47.299821-18.39993-91.699653-51.799804-125.199525z"
                fill="#27D0D8"
                p-id="2182"
              ></path>
            </svg>
          </el-card>
        </a>
        <br/>
        <el-pagination
          style="text-align: center;"
          background
          @current-change="currentChangeHandle"
          :current-page="pageIndex"
          :page-size="pageSize"
          :total="totalPage"
          layout="prev, next"
        ></el-pagination>
        <br>
        <a style="cursor: pointer;text-decoration: none;" @click="requirement">
          <el-card class="cursor" shadow="never">要求</el-card>
        </a>
        <br/>
        <a style="cursor: pointer;text-decoration: none;" @click="giveFood">
          <el-card class="cursor" shadow="never">赠菜</el-card>
        </a>
        <br/>
        <a style="cursor: pointer;text-decoration: none;" @click="retreat">
          <el-card class="cursor" shadow="never">退菜</el-card>
        </a>
        <br/>
        <a style="cursor: pointer;text-decoration: none;" @click="changePri">
          <el-card class="cursor" shadow="never">改价</el-card>
        </a>
        <br/>
        <a style="cursor: pointer;text-decoration: none;" @click="setNum">
          <el-card class="cursor" shadow="never">数量</el-card>
        </a>
        <br/>
        <a style="cursor: pointer;text-decoration: none;" @click="deleteFood">
          <el-card class="cursor" shadow="never">删除</el-card>
        </a>
        <br/>
        <a style="cursor: pointer;text-decoration: none;" @click="changeFoodDiscount">
          <el-card class="cursor" shadow="never">折扣</el-card>
        </a>
        <br/>
        <div>
          <el-popover placement="right" width="150" trigger="click">
            <a style="cursor: pointer;text-decoration: none;" @click="singleFoodTransfe">
              <el-card class="cursor" shadow="never">单品转菜</el-card>
            </a>
            <br/>
            <a style="cursor: pointer;text-decoration: none;" @click="orderTransfe">
              <el-card class="cursor" shadow="never">整单转菜</el-card>
            </a>
            <br/>
            <a style="cursor: pointer;text-decoration: none;" @click="copyOrder">
              <el-card class="cursor" shadow="never">整单复制</el-card>
            </a>
            <br/>
            <a slot="reference" style="cursor: pointer;text-decoration: none;">
              <el-card class="cursor" shadow="always" style="text-align: center;">更多</el-card>
            </a>
          </el-popover>
        </div>
        <br/>
      </el-col>
      <el-col :span="16" style="height: 46.75rem;">
        <el-tabs type="card" v-model="activeName" @tab-click="getFoodList">
          <el-tab-pane label="全部" name="0">
            <el-row :gutter="12">
              <el-col :span="6" v-for="item in foodList" :key="item.id">
                <a style="cursor: pointer;text-decoration: none;" @click="selelctFood(item)">
                  <div style="height: 100px;border: 0.0125rem solid lightgray;border-radius: 0.25rem;">
                    <el-row :gutter="3">
                      <el-col :span="14">
                        <img v-show="item.foodImg !==''" style="width: 100%;height: 98px;" :src="item.foodImg"/>
                        <img v-show="item.foodImg ===''" style="width: 100%;height: 98px"
                             src="../../../assets/img/no-img1.png"/>
                      </el-col>
                      <el-col :span="10">
                        <div style="padding-top: 1.25rem;">
                          <div class="cursor" style="color: #000000;">
                            {{ item.foodName }}
                            <span v-if="item.sellOffStatus === 0" style="color: #f93e3e">(售罄)</span>
                          </div>
                          <br>
                          <div class="cursor" style="color: red;">￥{{ item.price }}元</div>
                        </div>
                      </el-col>
                    </el-row>
                  </div>
                </a>
                <br/>
              </el-col>
            </el-row>
          </el-tab-pane>
          <el-tab-pane v-for="item in foodTypeList" :key="item.id" :label="item.classificationName" :name="item.id">
            <el-row :gutter="12">
              <el-col :span="6" v-for="items in foodList" :key="item.id">
                <a style="cursor: pointer;text-decoration: none;" @click="selelctFood(items)">
                  <div style="height: 100px;border: 0.0125rem solid lightgray;border-radius: 0.25rem;">
                    <el-row :gutter="3">
                      <el-col :span="14">
                        <img v-show="items.foodImg !==''" style="width: 100%;height: 98px;" :src="items.foodImg"/>
                        <img v-show="items.foodImg ===''" style="width: 100%;height: 98px"
                             src="../../../assets/img/no-img1.png"/>
                      </el-col>
                      <el-col :span="10">
                        <div style="padding-top: 1.25rem;">
                          <div class="cursor" style="color: #000000;">{{ items.foodName }}</div>
                          <br>
                          <div class="cursor" style="color: red;">￥{{ items.price }}元</div>
                        </div>
                      </el-col>
                    </el-row>
                  </div>
                </a>
                <br/>
              </el-col>
            </el-row>
          </el-tab-pane>
        </el-tabs>
      </el-col>
    </el-row>

    <!-- 要求 -->
    <el-dialog title="要求" :visible.sync="requirementVisible" :close-on-click-modal="false" width="30%" center>
      <el-checkbox-group v-model="requirementIdList">
        <el-checkbox border size="medium" v-for="f in requirementList" :key="f.requirementId" :label="f.requirementId">
          {{ f.requirementName }}
        </el-checkbox>
      </el-checkbox-group>
      <br/>
      <el-input v-model="customRequirement" placeholder="自定义要求"></el-input>
      <span slot="footer" class="dialog-footer">
				<el-button @click="requirementVisible = false">取消</el-button>
				<el-button type="primary" @click="getRequirements()">确定</el-button>
			</span>
    </el-dialog>

    <!-- 退菜 -->
    <el-dialog title="退菜" :visible.sync="reasonVisible" :close-on-click-modal="false" width="40%" center>
      <div>
        <div style="width: 50%;float: left;">
          <div>退菜理由</div>
          <br/>
          <el-radio-group v-model="retreatFoodIdList">
            <el-radio border size="medium" v-for="f in retreatFoodList" :key="f.reasonDetailId"
                      :label="f.reasonDetailId">{{ f.reasonDetailName }}
            </el-radio>
          </el-radio-group>
        </div>
        <el-card shadow="never" style="width: 50%;float: right;">
          <div style="font-size: 1.25rem;">
            退菜数量,最多可退:
            <span style="color: red;">[{{ foodItemInfo.foodNum }}]</span>
          </div>
          <br/>
          <KeyBN ref="keyBoardRef" @getEatNum="getRetreatNum"></KeyBN>
        </el-card>
      </div>
      <span slot="footer" class="dialog-footer">
				<el-button @click="reasonVisible = false">取消</el-button>
				<el-button type="primary" @click="retreatFood()">确定</el-button>
			</span>
    </el-dialog>

    <!-- 赠菜 -->
    <el-dialog title="赠菜" :visible.sync="giveFoodVisible" :close-on-click-modal="false" width="40%" center>
      <el-row :gutter="20">
        <el-col :span="12">
          <div>赠菜理由</div>
          <br/>
          <el-row :gutter="10">
            <el-radio-group v-model="retreatFoodIdList">
              <el-col :span="12" v-for="c in giveFoodReasonList" :key="c.reasonDetailId">
                <el-radio border size="medium" :label="c.reasonDetailId">{{ c.reasonDetailName }}</el-radio>
              </el-col>
            </el-radio-group>
          </el-row>
        </el-col>
        <el-col :span="12">
          <el-card shadow="never">
            <div style="font-size: 1.25rem;">
              赠菜数量,最多可赠:
              <span style="color: red;">[{{ foodItemInfo.foodNum }}]</span>
            </div>
            <br/>
            <KeyBN ref="keyBoardRef" @getEatNum="getRetreatNum"></KeyBN>
          </el-card>
        </el-col>
      </el-row>
      <span slot="footer" class="dialog-footer">
				<el-button @click="giveFoodVisible = false">取消</el-button>
				<el-button type="primary" @click="submitGiveFood()">确定</el-button>
			</span>
    </el-dialog>

    <!-- 单品转菜 -->
    <el-dialog title="单品转菜" :visible.sync="singleFoodTransfeVisle" :close-on-click-modal="false" width="40%" center>
      <el-row :gutter="30">
        <el-form :inline="true" label-width="80px">
          <el-col :span="12">
            <el-form-item label="菜品:">{{ foodItemInfo.foodName }}</el-form-item>
            <br/>
            <el-form-item label="桌号:">{{ openDeskInfo.diningTableNo }}</el-form-item>
            <br/>
            <el-form-item label="转到桌位:">
              <el-button type="primary" icon="el-icon-plus" @click="selectDesk">选择桌位</el-button>
              &nbsp;&nbsp;&nbsp;
              <span style="font-size: 1.25rem;color: #04B404;">[{{ deskInfos.diningTableNo }}]</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item>
              转菜数量:最多只能转
              <span style="font-size: 15px;color: red;font-weight: 500;">【{{ foodItemInfo.foodNum }}】</span>
              份
              <KeyBN ref="keyBoardNumRef" @getEatNum="selectNum"></KeyBN>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <span slot="footer" class="dialog-footer">
				<el-button @click="singleFoodTransfeVisle = false">取消</el-button>
				<el-button type="primary" @click="submitsingleFoodTransfe()">确定</el-button>
			</span>
    </el-dialog>

    <el-dialog :visible.sync="changeDiscountVisible" width="25%">
      <ChangeDiscountKeyBoard @getDiscountMoney="discountNumber" ref="KeyBordPointRef"></ChangeDiscountKeyBoard>
    </el-dialog>
    <KeyB ref="keyBoardRef" @getEatNum="eatNum"></KeyB>

    <SeatCom @getDeskInfo="deskInfo" v-if="seatComVisile" ref="SeatComRef"></SeatCom>

    <CopyOrder @refreshDataList="getDataList" v-if="copyOrderVisile" ref="copyOrderRef"></CopyOrder>

    <!-- 改价 -->
    <el-dialog :visible.sync="changePriceVisible" width="25%">
      <ChangePriceKeyBoard @getDiscountMoney="changePriceNumber" ref="ChangePriceKeyBoardRef"></ChangePriceKeyBoard>
    </el-dialog>


    <SmallTicket @DataIsNull="toPan" v-show="TicketVisle" ref="TicketRef"></SmallTicket>

    <PayCom @refreshDataList="toSeatPage" v-if="PayComponentVisible" ref="PayComponentRef"></PayCom>
  </div>
</template>

<script>
import Ticket from '../../modules/store/noSider/ticket/ticket.vue'
import EnglishKeyBord from './EnglishKeyBord.vue'
import KeyBordPoint from './KeyBordPoint.vue'
import KeyB from './KeyBoard.vue'
import SeatCom from './SeatComCopy.vue'
import KeyBN from './KeyBoardNum.vue'
import CopyOrder from '../tangshi/TransfeOrder.vue'
import SmallTicket from '../../modules/common/printTemplate/TangShi/FoodItemPrint.vue'
import PayCom from './PayComponent.vue'
import ChangePriceKeyBoard from './ChangePriceKeyBoard.vue'
import ChangeDiscountKeyBoard from './ChangeDiscountKeyBorad'
import {keepTwoPoint} from '../../../utils'

export default {
  components: {
    Ticket,
    EnglishKeyBord,
    KeyBordPoint,
    KeyB,
    SeatCom,
    KeyBN,
    CopyOrder,
    SmallTicket,
    PayCom,
    ChangePriceKeyBoard,
    ChangeDiscountKeyBoard
  },
  data () {
    return {
      changeDiscountVisible: false,
      changePriceVisible: false,
      TicketVisle: false,
      foodTypeList: [],
      foodList: [],
      activeName: 0,
      selectFoodList: [],
      foodIdList: [],
      totalMoney: 0,
      num: 0,
      index: 0,
      idArray: [],
      openDeskInfo: '',
      requirementVisible: false,
      requirementList: [],
      requirementIdList: [],
      requireStyle: '',
      customRequirement: '',
      requireArray: [],
      selectFoodId: 0,
      requirementStr: '',
      giveFoodVisible: false,
      giveFoodReasonList: [],
      giveFoodReasonId: '',
      foodItemInfo: '',
      fastFoodNumberVisible: false,
      number: 1,
      priceVisible: false,
      changePrice: '',
      changeDiscountVisible: false,
      changeDiscount: 1,
      shortCode: '',
      vueKeyboardVisle: false,
      EnglishKeyBordVisle: false,
      lett: '',
      closeKeyboard: false,
      singleFoodTransfeVisle: false,
      seatComVisile: false,
      deskInfos: '',
      transfeFoodNum: '',
      allFoodTransSign: 1,
      sourceDesk: '',
      copyOrderVisile: false,
      PayComponentVisible: false,
      changePriNumber: '',
      orderInfo: {},
      retreatFoodList: [],
      reasonVisible: false,
      retreatFoodNum: 0,
      retreatFoodIdList: [],
      giveFoodNum: '',
      isAddSign: '',
      pageIndex: 1,
      pageSize: 24,
      totalPage: 0,
      typeId: 0,
      changeFoodDisSign: '',
      bakTotal: 0
    }
  },
  created () {
    this.init()
    this.getFoodTypeList()
    this.getDataList()
  },

  methods: {
    getRetreatNum (num) {
      this.retreatFoodNum = num
    },

    getGiveNum (num) {
      this.giveFoodNum = num
    },

    retreat () {
      if (this.foodItemInfo === '') {
        this.$message({
          message: '请选择菜品',
          type: 'warning',
          duration: 1500
        })
      } else if (this.foodItemInfo.placeOrderSign !== 1) {
        this.$message({
          type: 'warning',
          message: '未下单的菜品不能退菜'
        })
      } else {
        this.$nextTick(() => {
          this.$refs.keyBoardNumRef.init('请输入份数')
        })
        this.$http({
          url: this.$http.adornUrl('/store/tstorereasondetail/list'),
          method: 'get',
          params: this.$http.adornParams({
            page: 1,
            limit: 100,
            key: '',
            reasonId: 2
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.retreatFoodList = data.page.list
            this.reasonVisible = true
          } else {
            this.retreatFoodList = []
          }
        })
      }
    },

    toSeatPage () {
      this.$router.push({name: 'TangShi'})
    },

    jiezhang () {
      this.selectFoodList.forEach(item => {
        if (item.placeOrderSign === undefined) {
          this.isAddSign = 1
        }
      })
      // 有未下单的菜(先下单)
      if (this.isAddSign === 1) {
        this.$confirm('新增菜品是否需要下单?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            this.openDeskInfo.totalMoney = this.totalMoney
            // 已经下单标识（菜品）
            const arr = []
            this.selectFoodList.forEach(item => {
              item.discountMoney = null
              item.placeOrderSign = 1
              arr.push(item)
            })
            this.openDeskInfo.foodVos = arr
            this.$http({
              url: this.$http.adornUrl(`/reception/tstoreopendesk/xiadan`),
              method: 'post',
              data: this.$http.adornData({
                orderInfo: this.openDeskInfo
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '下单成功',
                  type: 'success',
                  duration: 1500
                })
                // 结账
                this.PayComponentVisible = true
                this.isAddSign = ''
                const openDeskInfo = {
                  master: this.openDeskInfo.master,
                  slave: this.openDeskInfo.slave,
                  masterId: this.openDeskInfo.masterId,
                  id: this.openDeskInfo.id
                }
                this.orderInfo = this.openDeskInfo
                this.orderInfo.totalMoney = this.totalMoney
                this.orderInfo.openDeskInfo = openDeskInfo
                this.orderInfo.foodVos = this.selectFoodList
                this.$nextTick(() => {
                  this.$refs.PayComponentRef.init(this.orderInfo)
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          })
          .catch(() => {
            // 取消下单并清除已选未下单的菜品
            const arr = []
            this.selectFoodList.forEach(item => {
              if (item.placeOrderSign === 1) {
                arr.push(item)
              } else {
                this.totalMoney -= item.total
              }
            })
            this.selectFoodList = arr
            this.$message({
              type: 'info',
              message: '已取消下单'
            })
          })
      } else {
        this.PayComponentVisible = true
        const openDeskInfo = {
          master: this.openDeskInfo.master,
          slave: this.openDeskInfo.slave,
          masterId: this.openDeskInfo.masterId,
          id: this.openDeskInfo.id
        }
        this.orderInfo = this.openDeskInfo
        this.orderInfo.totalMoney = this.totalMoney
        this.orderInfo.openDeskInfo = openDeskInfo
        this.orderInfo.foodVos = this.selectFoodList
        this.$nextTick(() => {
          this.$refs.PayComponentRef.init(this.orderInfo)
        })
      }
    },

    copyOrder () {
      this.copyOrderVisile = true
      // this.openDeskInfo.storeTypeId = this.activeStoreType;
      this.$nextTick(() => {
        this.$refs.copyOrderRef.init(this.openDeskInfo)
      })
    },

    // 整单转菜
    orderTransfe () {
      this.seatComVisile = true
      this.allFoodTransSign = 1 // 整单转菜标识
      this.$nextTick(() => {
        this.$refs.SeatComRef.init(2, this.openDeskInfo.storeTypeId, '整单转菜')
      })
    },

    submitsingleFoodTransfe () {
      if (this.deskInfos === '' || this.transfeFoodNum === '') {
        this.$message({
          message: '请选择桌位或输入转菜数量',
          type: 'warning',
          duration: 1500
        })
      }
      if (this.transfeFoodNum > this.foodItemInfo.foodNum) {
        this.$message({
          message: '转菜数量大于原有数量',
          type: 'warning',
          duration: 1500
        })
      } else {
        // 获取目标台的订单信息
        this.$http({
          url: this.$http.adornUrl('/reception/tstoreopendesk/queryOrderInfo/' + this.deskInfos.id),
          method: 'get'
        }).then(({data}) => {
          if (data && data.code === 0) {
            // 更新原餐台数据
            const arr = []
            this.selectFoodList.forEach(item => {
              item.placeOrderSign = 1
              if (item.id === this.foodItemInfo.id) {
                if (item.foodNum > 1) {
                  item.foodNum -= Number(this.transfeFoodNum)
                  item.total -= Number(item.price) * Number(this.transfeFoodNum)
                  this.openDeskInfo.totalMoney -= Number(item.price) * Number(this.transfeFoodNum)
                  arr.push(item)
                } else {
                  this.openDeskInfo.totalMoney -= Number(item.price)
                }
              } else {
                arr.push(item)
              }
            })

            this.openDeskInfo.foodVos = arr
            this.$http({
              url: this.$http.adornUrl(`/reception/tstoreopendesk/xiadan`),
              method: 'post',
              data: this.$http.adornData({
                orderInfo: this.openDeskInfo
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '单品转菜成功',
                  type: 'success',
                  duration: 1500
                })
              } else {
                this.$message.error(data.msg)
              }
            })

            // 更新目标餐台数据
            const orderInfo = data.openDeskInfo.foodVos
            this.foodItemInfo.singleFoodSign = 1
            orderInfo.push(this.foodItemInfo)
            this.openDeskInfo.totalMoney = 0
            orderInfo.forEach(item => {
              this.openDeskInfo.totalMoney += item.total
            })
            this.openDeskInfo.foodVos = orderInfo
            this.openDeskInfo.id = this.deskInfos.id
            this.openDeskInfo.diningTableNo = this.deskInfos.diningTableNo
            this.openDeskInfo.eatNumer = data.openDeskInfo.eatNumer
            this.openDeskInfo.openTime = data.openDeskInfo.openTime
            this.openDeskInfo.orderId = data.openDeskInfo.orderId
            this.$http({
              url: this.$http.adornUrl(`/reception/tstoreopendesk/xiadan`),
              method: 'post',
              data: this.$http.adornData({
                orderInfo: this.openDeskInfo
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '单品转菜成功',
                  type: 'success',
                  duration: 1500
                })
                this.transfeFoodNum = ''
                this.foodItemInfo = ''
                this.deskInfos.diningTableNo = ''
                this.singleFoodTransfeVisle = false
                this.init()
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    },

    // 选择座位
    selectDesk () {
      this.seatComVisile = true
      this.$nextTick(() => {
        this.$refs.SeatComRef.init(2, this.openDeskInfo.storeTypeId, '单品转菜')
      })
    },

    singleFoodTransfe () {
      this.allFoodTransSign = 0
      if (this.foodItemInfo === '') {
        this.$message({
          message: '请选择菜品',
          type: 'warning',
          duration: 1500
        })
      } else {
        this.singleFoodTransfeVisle = true
        this.$refs.keyBoardNumRef.init('请输入份数')
      }
    },

    deskInfo (info) {
      this.deskInfos = info
      if (this.allFoodTransSign === 1) {
        this.$http({
          url: this.$http.adornUrl('/reception/tstoreopendesk/queryOrderInfo/' + this.deskInfos.id),
          method: 'get'
        }).then(({data}) => {
          if (data && data.code === 0) {
            // 更新原餐台数据
            const arr = this.sourceDesk.foodVos
            this.sourceDesk.foodVos = []
            this.sourceDesk.totalMoney = 0
            this.$http({
              url: this.$http.adornUrl(`/reception/tstoreopendesk/xiadan`),
              method: 'post',
              data: this.$http.adornData({
                orderInfo: this.sourceDesk
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '单品转菜成功',
                  type: 'success',
                  duration: 1500
                })
              } else {
                this.$message.error(data.msg)
              }
            })
            console.log('target  ' + JSON.stringify(this.openDeskInfo))
            // 更新目标餐台数据
            const orderInfo = data.openDeskInfo.foodVos
            arr.forEach(item => {
              item.singleFoodSign = 1
              orderInfo.push(item)
            })
            this.openDeskInfo.totalMoney = 0
            orderInfo.forEach(item => {
              this.openDeskInfo.totalMoney += item.total
            })
            this.openDeskInfo.foodVos = orderInfo
            this.openDeskInfo.id = this.deskInfos.id
            this.openDeskInfo.diningTableNo = this.deskInfos.diningTableNo
            this.openDeskInfo.eatNumer = data.openDeskInfo.eatNumer
            this.openDeskInfo.openTime = data.openDeskInfo.openTime
            this.openDeskInfo.orderId = data.openDeskInfo.orderId
            this.$http({
              url: this.$http.adornUrl(`/reception/tstoreopendesk/xiadan`),
              method: 'post',
              data: this.$http.adornData({
                orderInfo: this.openDeskInfo
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '单品转菜成功',
                  type: 'success',
                  duration: 1500
                })
                this.singleFoodTransfeVisle = false
                this.init()
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    },

    selectNum (num) {
      this.transfeFoodNum = num
    },

    getLett (lett) {
      if (lett === 'close') {
        this.EnglishKeyBordVisle = false
        this.shortCode = ''
        this.getDataList()
      } else {
        if (lett === '') {
          this.shortCode = ''
          this.getDataList()
        } else {
          this.shortCode = lett
          this.$http({
            url: this.$http.adornUrl('/store/tstorefood/getFoodListByShortCode'),
            method: 'get',
            params: this.$http.adornParams({
              shortCode: this.shortCode
            })
          }).then(({data}) => {
            if (data && data.code === 0) {
              if (data.page !== null) {
                this.foodList = data.page
              } else {
                this.foodList = []
              }
            } else {
              this.foodList = []
            }
          })
        }
      }
    },

    toPan () {
      this.print()
    },

    print () {
      this.orderInfo.eatType = '堂吃'
      this.orderInfo = this.openDeskInfo
      this.$nextTick(() => {
        this.$refs.TicketRef.printPdf(this.orderInfo)
      })
    },

    // 改变菜品折扣
    discountNumber (changeDiscount) {
      this.changeDiscount = changeDiscount
      var row = this.foodItemInfo
      this.bakTotal = row.total
      this.changeFoodDisSign = 1
      if (this.changeDiscount !== 1) {
        this.totalMoney -= row.total
        row.total = keepTwoPoint((Number(row.foodNum) * Number(row.price) * Number(this.changeDiscount)) / 10)
        // row.price = keepTwoPoint((Number(row.price) * Number(this.changeDiscount)) / 10);
        row.discount = changeDiscount
      } else {
        this.totalMoney -= row.total
        row.total = keepTwoPoint((Number(row.foodNum) * Number(row.price) * Number(this.changeDiscount)) / 10)
        // row.price = keepTwoPoint(Number(row.price) * Number(this.changeDiscount));
        row.discount = changeDiscount
      }
      this.totalMoney += row.total
      this.selectFoodList.push(row)
      this.selectFoodList = Array.from(new Set(this.selectFoodList))
      this.changeDiscountVisible = false
    },

    // 改价
    changePriceNumber (num) {
      this.changePriNumber = num
      if (this.foodItemInfo.placeOrderSign) {
        this.$message({
          type: 'info',
          message: '已下单菜品不能改变价格'
        })
      } else if (Number(num) > this.foodItemInfo.price) {
        this.$message.info('改价金额不能大于菜品原价')
      } else {
        var row = this.foodItemInfo
        this.totalMoney -= Number(row.total)
        // row.price = Number(this.changePriNumber);
        row.total = num
        this.totalMoney += Number(row.total)
        this.selectFoodList.push(row)
        this.selectFoodList = Array.from(new Set(this.selectFoodList))
        this.changePriceVisible = false
      }
    },

    changePri () {
      if (this.foodItemInfo.placeOrderSign) {
        this.$message({
          type: 'info',
          message: '已下单菜品不能改变价格'
        })
      } else if (this.foodItemInfo === '') {
        this.$message({
          message: '请选择菜品',
          type: 'warning',
          duration: 1500
        })
      } else {
        this.changePriceVisible = true
        this.$nextTick(() => {
          this.$refs.ChangePriceKeyBoardRef.init('改价为:')
        })
      }
    },

    // 退菜
    retreatFood () {
      if (this.foodItemInfo === '') {
        this.$message({
          message: '请选择菜品',
          type: 'warning',
          duration: 1500
        })
      } else if (this.foodItemInfo.placeOrderSign !== 1) {
        this.$message({
          type: 'warning',
          message: '未下单的菜品不能退菜'
        })
      } else if (this.retreatFoodNum > this.foodItemInfo.foodNum) {
        this.$message({
          type: 'warning',
          message: '可退数量大于输入数量'
        })
      } else if (this.retreatFoodNum === 0) {
        this.$message({
          type: 'warning',
          message: '请输入退菜数量'
        })
      } else {
        for (let i = 0; i < this.openDeskInfo.foodVos.length; i++) {
          if (this.openDeskInfo.foodVos[i].id === this.foodItemInfo.id) {
            // 多份
            if (this.openDeskInfo.foodVos[i].foodNum > 1) {
              this.openDeskInfo.totalMoney -= this.openDeskInfo.foodVos[i].price
              this.totalMoney -= this.openDeskInfo.foodVos[i].price
              // this.openDeskInfo.foodVos[i].foodNum -= this.retreatFoodNum;
            } else {
              this.openDeskInfo.totalMoney -= this.openDeskInfo.foodVos[i].price
              this.totalMoney -= this.openDeskInfo.foodVos[i].price
              // this.openDeskInfo.foodVos.splice(i, 1);
            }
            this.openDeskInfo.foodVos[i].retreatSign = 1
            this.openDeskInfo.foodVos[i].retreatNum = this.retreatFoodNum
          }
        }
        // 更新数据
        this.$http({
          url: this.$http.adornUrl(`/reception/tstoreopendesk/xiadan`),
          method: 'post',
          data: this.$http.adornData({
            orderInfo: this.openDeskInfo
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '退菜成功',
              type: 'success',
              duration: 1500
            })
            this.reasonVisible = false
          } else {
            this.$message.error(data.msg)
          }
        })
      }
    },

    setNum () {
      if (this.foodItemInfo.placeOrderSign) {
        this.$message({
          type: 'info',
          message: '已下单菜品不能改变数目'
        })
      } else if (this.foodItemInfo === '') {
        this.$message({
          message: '请选择菜品',
          type: 'warning',
          duration: 1500
        })
      } else {
        this.$nextTick(() => {
          this.$refs.keyBoardRef.init('请输入份数')
        })
      }
    },

    changeFoodDiscount () {
      if (this.foodItemInfo.placeOrderSign) {
        this.$message({
          type: 'info',
          message: '已下单菜品不能改变折扣'
        })
      } else if (this.foodItemInfo === '') {
        this.$message({
          message: '请选择菜品',
          type: 'warning',
          duration: 1500
        })
      } else {
        this.changeDiscountVisible = true
        this.$nextTick(() => {
          this.$refs.KeyBordPointRef.init('请输入折扣')
        })
      }
    },

    // 删除菜品
    deleteFood () {
      if (this.foodItemInfo.placeOrderSign) {
        this.$message({
          type: 'info',
          message: '已下单菜品不能删除'
        })
      } else if (this.foodItemInfo === '') {
        this.$message({
          message: '请选择菜品',
          type: 'warning',
          duration: 1500
        })
      } else {
        var row = this.foodItemInfo
        if (row.foodNum > 1) {
          row.foodNum--
          row.total = Number(row.foodNum) * Number(row.price)
          this.totalMoney -= row.price
          this.selectFoodList.push(row)
          this.selectFoodList = Array.from(new Set(this.selectFoodList))
        } else {
          var idNewArray = []
          for (let s = 0; s < this.idArray.length; s++) {
            if (row.id !== this.idArray[s]) {
              idNewArray.push(this.idArray[s])
            }
          }
          this.idArray = idNewArray
          this.num--
          this.totalMoney -= row.price
          // TODO
          var newArr = []
          for (let i = 0; i < this.selectFoodList.length; i++) {
            this.selectFoodList[i].index = i
            newArr.push(this.selectFoodList[i])
          }
          this.selectFoodList = newArr
          this.selectFoodList.splice(row.index, 1)
        }
        this.foodItemInfo = ''
      }
    },

    // 菜品数量
    eatNum (number) {
      this.number = number
      if (this.foodItemInfo.placeOrderSign) {
        this.$message({
          type: 'info',
          message: '已下单菜品不能改变份数'
        })
      } else if (this.foodItemInfo === '') {
        this.$message({
          message: '请选择菜品',
          type: 'warning',
          duration: 1500
        })
      } else {
        var row = this.foodItemInfo
        row.foodNum = this.number
        this.totalMoney -= row.total
        row.total = Number(row.foodNum) * Number(row.price)
        this.totalMoney += row.total
        this.selectFoodList.push(row)
        this.selectFoodList = Array.from(new Set(this.selectFoodList))
        this.fastFoodNumberVisible = false
      }
    },

    // 改价
    // submitChangePrice(){
    // 	if(this.foodItemInfo.placeOrderSign){
    // 		this.$message({
    // 			type: 'info',
    // 			message: '已下单菜品不能改变价格'
    // 		});
    // 	}else{
    // 		var row = this.foodItemInfo
    // 		this.totalMoney -= Number(row.price);
    // 		row.price = Number(this.changePriNumber)
    // 		row.total = Number(row.foodNum) * Number(row.price);
    // 		this.totalMoney += Number(row.price);
    // 		this.selectFoodList.push(row);
    // 		this.selectFoodList = Array.from(new Set(this.selectFoodList));
    // 		this.priceVisible = false;
    // 	}

    // },

    openDesk () {
      this.$router.push({name: 'TangShi'})
    },

    // 提交赠菜
    submitGiveFood () {
      if (this.retreatFoodNum > this.foodItemInfo.foodNum) {
        this.$message({
          type: 'warning',
          message: '可赠数量大于输入数量'
        })
      } else if (this.retreatFoodNum === 0) {
        this.$message({
          type: 'warning',
          message: '请输入赠菜数量'
        })
      } else {
        // TODO 赠菜这里有一个bug,已经下单的菜，如果又一次点单，点了重复的菜，那么之前点的那道菜也会变为赠送的状态，金额就对不上
        for (let i = 0; i < this.selectFoodList.length; i++) {
          if (this.selectFoodList[i].id === this.selectFoodId) {
            if (this.foodItemInfo.foodNum > 1) {
              this.openDeskInfo.totalMoney -= this.selectFoodList[i].price * this.retreatFoodNum
              this.totalMoney -= this.selectFoodList[i].price * this.retreatFoodNum
              // this.selectFoodList[i].foodNum -= this.retreatFoodNum;
              this.selectFoodList[i].total = this.selectFoodList[i].price * (this.selectFoodList[i].foodNum - this.retreatFoodNum)
            } else {
              this.openDeskInfo.totalMoney -= this.selectFoodList[i].price * this.retreatFoodNum
              this.totalMoney -= this.selectFoodList[i].price * this.retreatFoodNum
              this.selectFoodList[i].total = 0
            }
            this.selectFoodList[i].giveFoodReasonId = this.giveFoodReasonId
            this.selectFoodList[i].giveFoodStatus = 1
            this.selectFoodList[i].giveNum = this.retreatFoodNum
          }
        }
        this.giveFoodVisible = false
      }
    },

    // 赠菜
    giveFood () {
      if (this.foodItemInfo === '') {
        this.$message({
          message: '请选择菜品',
          type: 'warning',
          duration: 1500
        })
      } else {
        this.$nextTick(() => {
          this.$refs.keyBoardNumRef.init('请输入份数')
        })
        this.$http({
          url: this.$http.adornUrl('/store/tstorereasondetail/listGiveFood'),
          method: 'get',
          params: this.$http.adornParams({})
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.giveFoodReasonList = data.data
          } else {
            this.giveFoodReasonList = []
          }
        })
        this.giveFoodVisible = true
      }
    },

    getRequirements () {
      var requireArr = []
      for (let j = 0; j < this.requirementIdList.length; j++) {
        for (let i = 0; i < this.requirementList.length; i++) {
          if (this.requirementList[i].requirementId === this.requirementIdList[j]) {
            requireArr.push(this.requirementList[i].requirementName)
          }
        }
      }
      this.requireArray = requireArr
      for (let k = 0; k < this.requireArray.length; k++) {
        this.requirementStr += this.requireArray[k] + ' '
      }
      for (let i = 0; i < this.selectFoodList.length; i++) {
        if (this.selectFoodList[i].id === this.selectFoodId) {
          this.selectFoodList[i].requirementName = this.requirementStr + this.customRequirement
        }
      }
      this.requirementVisible = false
    },

    superRequirement (row, column, event) {
      console.log('data   ' + JSON.stringify(row))
      this.requirementStr = ''
      this.customRequirement = ''
      this.requirementIdList = []
      this.selectFoodId = row.id
      this.foodItemInfo = row
      // this.requireStyle = 'background-color: #F08080;color:white';
    },

    requirement () {
      if (this.foodItemInfo.placeOrderSign) {
        this.$message({
          type: 'info',
          message: '已下单菜品不能设置要求'
        })
      } else if (this.foodItemInfo === '') {
        this.$message({
          message: '请选择菜品',
          type: 'warning',
          duration: 1500
        })
      } else {
        this.requirementVisible = true
        this.$http({
          url: this.$http.adornUrl('/store/tstorerequirement/list'),
          method: 'get',
          params: this.$http.adornParams({})
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.requirementList = data.page.list
          } else {
            this.requirementList = []
          }
        })
      }
    },

    // 下单
    xiadan () {
      if (this.selectFoodList.length < 1) {
        this.$message({
          message: '请选择菜品后下单',
          type: 'success',
          duration: 1500
        })
      } else {
        this.openDeskInfo.totalMoney = this.totalMoney
        // 已经下单标识（菜品）
        const arr = []
        this.selectFoodList.forEach(item => {
          item.placeOrderSign = 1
          arr.push(item)
        })
        this.openDeskInfo.foodVos = arr
        this.$http({
          url: this.$http.adornUrl(`/reception/tstoreopendesk/xiadan`),
          method: 'post',
          data: this.$http.adornData({
            orderInfo: this.openDeskInfo
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '下单成功',
              type: 'success',
              duration: 1500
            })
            this.$router.push({name: 'TangShi'})
          } else {
            this.$message.error(data.msg)
          }
        })
      }
    },

    // 清空
    clearSelectFood () {
      if (this.selectFoodList.length === 0) {
        this.$message({
          type: 'danger',
          message: '当前无选中菜品'
        })
      } else {
        this.$confirm('你确定要清空所选菜品吗,?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            const arr = []
            this.selectFoodList.forEach(item => {
              if (item.placeOrderSign === 1) {
                arr.push(item)
              } else {
                this.totalMoney -= item.total
              }
            })
            this.selectFoodList = arr
            this.idArray = []
            this.num = 0
            this.index = 0

            this.foodIdList = []
            this.$message({
              type: 'success',
              message: '清除成功!'
            })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消清除'
            })
          })
      }
    },

    // 添加菜品份数
    addFood (row) {
      if (row.placeOrderSign) {
        this.$message({
          type: 'info',
          message: '已下单菜品不能添加份数'
        })
      } else {
        row.foodNum++
        row.total = Number(row.foodNum) * Number(row.price)
        this.totalMoney += row.price
        this.selectFoodList.push(row)
        this.selectFoodList = Array.from(new Set(this.selectFoodList))
      }
    },
    // 移除菜品
    removeFood (row) {
      if (row.placeOrderSign) {
        this.$message({
          type: 'info',
          message: '已下单菜品不能移除'
        })
      } else {
        if (row.foodNum > 1) {
          row.foodNum--
          row.total = Number(row.foodNum) * Number(row.price)
          this.totalMoney -= row.price
          this.selectFoodList.push(row)
          this.selectFoodList = Array.from(new Set(this.selectFoodList))
        } else {
          var idNewArray = []
          for (let s = 0; s < this.idArray.length; s++) {
            if (row.id !== this.idArray[s]) {
              idNewArray.push(this.idArray[s])
            }
          }
          this.idArray = idNewArray
          this.num--
          this.totalMoney -= row.price
          // TODO
          var newArr = []
          for (let i = 0; i < this.selectFoodList.length; i++) {
            this.selectFoodList[i].index = i
            newArr.push(this.selectFoodList[i])
          }
          this.selectFoodList = newArr
          this.selectFoodList.splice(row.index, 1)
        }
      }
    },

    // 选择菜品
    selelctFood (food) {
      // 售罄
      if (food.sellOffStatus === 0) {
        this.$message.warning(food.foodName + '已售罄！')
        return
      }
      // window.speechSynthesis.speak(new window.SpeechSynthesisUtterance(food.foodName+",单价"+food.price))
      food.foodSign = 1
      food.index = this.num
      if (food.index === 0) {
        this.idArray.push(food.id)
        food.foodNum = 1
        food.total = food.price
        // 数据索引
        food.index = this.num
        this.num++
        this.selectFoodList.push(food)
        this.selectFoodList = Array.from(new Set(this.selectFoodList))
        this.totalMoney += Number(food.price)
      } else {
        if (!this.idArray.includes(food.id)) {
          this.idArray.push(food.id)
          food.foodNum = 1
          food.total = food.price
          // 数据索引
          food.index = this.num
          this.num++
          this.selectFoodList.push(food)
          this.selectFoodList = Array.from(new Set(this.selectFoodList))
          this.totalMoney += Number(food.price)
        }
      }
    },

    getFoodTypeList () {
      // 获取菜品分类
      this.$http({
        url: this.$http.adornUrl('/store/tstorefoodtype/list'),
        method: 'get',
        params: this.$http.adornParams({
          page: 1,
          limit: 100,
          key: ''
        })
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.foodTypeList = data.page.list
        } else {
          this.foodTypeList = []
          this.totalPage = 0
        }
      })
    },

    init (params) {
      // 开台
      var info = JSON.parse(sessionStorage.getItem('openDeskInfo'))
      if (info.sign === 1) {
        this.openDeskInfo = JSON.parse(sessionStorage.getItem('openDeskInfo'))
      }
      // 加菜
      else {
        this.$http({
          url: this.$http.adornUrl('/reception/tstoreopendesk/queryOrderInfo/' + info.id),
          method: 'get'
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.sourceDesk = data.openDeskInfo
            this.openDeskInfo = data.openDeskInfo
            this.openDeskInfo.storeTypeId = info.storeTypeId
            this.openDeskInfo.addFood = true
            this.openDeskInfo.master = info.master
            this.openDeskInfo.slave = info.slave
            this.openDeskInfo.masterId = info.masterId
            this.selectFoodList = data.openDeskInfo.foodVos
            this.totalMoney = data.openDeskInfo.totalMoney
          } else {
            this.dataList = []
            this.totalPage = 0
          }
        })
      }
    },

    // 根据助词码获取菜品
    getFoodListByShortCode () {
      this.EnglishKeyBordVisle = true
    },

    // 当前页
    currentChangeHandle (val) {
      this.pageIndex = val
      this.getDataList()
    },

    getDataList () {
      this.$http({
        url: this.$http.adornUrl('/store/tstorefood/listFoodShow'),
        method: 'get',
        params: this.$http.adornParams({
          page: this.pageIndex,
          limit: this.pageSize,
          typeId: this.typeId,
          key: '',
          useRange: 1
        })
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.foodList = data.page.list
          this.totalPage = data.page.totalCount
        } else {
          this.foodList = []
          this.totalPage = 0
        }
      })
    },

    getFoodList (tab, event) {
      if (this.pageIndex > 1) {
        this.pageIndex = 1
      }

      var typeId = null
      if (tab === 0) {
        typeId = 0
      } else {
        typeId = tab.name
        this.typeId = typeId
      }
      this.$http({
        url: this.$http.adornUrl('/store/tstorefood/listFoodShow'),
        method: 'get',
        params: this.$http.adornParams({
          page: this.pageIndex,
          limit: this.pageSize,
          typeId: typeId,
          key: '',
          useRange: 1
        })
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.foodList = data.page.list
          this.totalPage = data.page.totalCount
        } else {
          this.foodList = []
          this.totalPage = 0
        }
      })
    }
  }
}
</script>

<style>
.cursor {
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
</style>
